<template>
  <div>
    <div v-for="(v,i) in barcodeList" :key="i" :id="`qrcode${i}`" class="barcode-box">
      <VueBarcode :value="v.code" :width="1" :height="25">
        Show this if the rendering fails.
      </VueBarcode>
      <div>
        <span style="margin-right: 15px">{{ peOrdersMain.customerName }}</span>
        <span style="margin-right: 15px">{{ peOrdersMain.sex|formatSex }}</span>
        <span style="margin-right: 15px">{{ peOrdersMain.age }}</span>
        <span style="margin-right: 15px">{{ peOrdersMain.company }}</span>
        <span style="margin-right: 15px">{{ v.itemName }}</span>
      </div>
    </div>
  </div>
</template>

<script>
import VueBarcode from 'vue-barcode';

export default {
  name: "barcodePrint",
  components: {
    VueBarcode,
  },
  data() {
    return {
      nowtime: "",
      // formInline:{},
      dialogFormVisible: true,
      formLabelWidth: '80px',
      rules: {},
      // data: this.order,
      barcodeList: this.order.barcodeList,
      peOrdersMain: this.order.peOrdersMain,
    }
  },
  props: {
    order: {
      type: Object,
      defalut: {}
    }
  },
  watch: {
    order(newValue, oldValue) {
      this.order = newValue;
      this.barcodeList = newValue.barcodeList
      this.peOrdersMain = newValue.peOrdersMain
      // console.log("watch",this.order);
    }
  },
  mounted() {
  },
  methods: {
    print() {
      this.barcodeList.forEach((item, $index) => {
        this.lodopQrcode(item)
      })
    },
    lodopQrcode(item) {
      console.log('item', item)
      console.log('data', this.peOrdersMain)
      // const index = window.localStorage.getItem('qrcodeIndex')
      // const pname = window.localStorage.getItem('qrcodeName')
      const str = `${this.peOrdersMain.customerName} ${this.peOrdersMain.age} ${this.peOrdersMain.sex == '1' ? '男' : '女'}`
      // if (index > -1 && index !== undefined && index !== null) {
        const lodop = window.LODOP
        // lodop.PRINT_INITA("0","0","50.00mm","30mm","");
        // lodop.ADD_PRINT_BARCODE("2mm","8.86mm","32.28mm","15.88mm","128B", item.code);
        // lodop.ADD_PRINT_TEXT("16.93mm","0.79mm","13.23mm","5.29mm", this.peOrdersMain.customerName);
        // lodop.ADD_PRINT_TEXT("16.93mm","14.55mm","7.94mm","5.29mm", this.peOrdersMain.sex == 1 ? '男' : '女');
        // lodop.ADD_PRINT_TEXT("16.93mm","23.28mm","7.94mm","5.29mm", this.peOrdersMain.age);
        // lodop.ADD_PRINT_TEXT("16.93mm","32.54mm","15.88mm","5.29mm", this.peOrdersMain.company);
        // lodop.ADD_PRINT_TEXT("23.28mm","1.06mm","47.36mm","6.35mm", item.itemName);
        // lodop.PRINT()
        lodop.PRINT_INIT()
        lodop.PRINT_INITA("0","0","50.00mm","30mm","")
        lodop.SET_LICENSES("","83A700E0C70546DE025B3B2260A1395DB69","","")
        lodop.SET_PRINTER_INDEXA('ticketPrint')
        lodop.ADD_PRINT_BARCODE("0mm","10mm","30mm","16mm","128B", item.code)
        lodop.ADD_PRINT_TEXT(65,6,180,20, str)
        lodop.ADD_PRINT_TEXT(85,6,180,20, item.itemName)
        lodop.PRINT()
      // } else {
        // this.$message.error('请先修改打印设置中指引单所使用的打印机')
      // }
    }
  }
}
</script>

<style lang="scss">

</style>
